{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Self Dividing Numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: selfDividingNumbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #自除数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p><strong>自除数</strong><em>&nbsp;</em>是指可以被它包含的每一位数整除的数。</p>\n",
    "\n",
    "<ul>\n",
    "\t<li>例如，<code>128</code> 是一个 <strong>自除数</strong> ，因为&nbsp;<code>128 % 1 == 0</code>，<code>128 % 2 == 0</code>，<code>128 % 8 == 0</code>。</li>\n",
    "</ul>\n",
    "\n",
    "<p><strong>自除数</strong> 不允许包含 0 。</p>\n",
    "\n",
    "<p>给定两个整数&nbsp;<code>left</code>&nbsp;和&nbsp;<code>right</code> ，返回一个列表，<em>列表的元素是范围&nbsp;<code>[left, right]</code>&nbsp;内所有的 <strong>自除数</strong></em> 。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>left = 1, right = 22\n",
    "<strong>输出：</strong>[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2:</strong></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>left = 47, right = 85\n",
    "<b>输出：</b>[48,55,66,77]\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= left &lt;= right &lt;= 10<sup>4</sup></code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [self-dividing-numbers](https://leetcode.cn/problems/self-dividing-numbers/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [self-dividing-numbers](https://leetcode.cn/problems/self-dividing-numbers/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['1\\n22', '47\\n85']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        numberlist = []\n",
    "        for number in range(left, right+1):\n",
    "            i = number\n",
    "            tag = True\n",
    "#            print(\"number is %d\" % number)\n",
    "            while(i):\n",
    "                if i%10 == 0:\n",
    "                    tag = False\n",
    "                    break;\n",
    "                else:                 \n",
    "                    temp = i%10\n",
    "#                    print(\"temp is %d\" %temp)\n",
    "                    if(number%temp > 0):\n",
    "                        tag = False\n",
    "                        break;\n",
    "                    else:\n",
    "                        i = i//10\n",
    "            if(tag and i == 0):\n",
    "                numberlist.append(number)\n",
    "        return numberlist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isdividingNumber(self,n):\n",
    "        s=str(n)\n",
    "        count=0\n",
    "        for item in s:\n",
    "            # print('item',item)\n",
    "            if int(item)!=0 and n % int(item)==0:\n",
    "                count+=1\n",
    "        if count==len(s):\n",
    "            return True\n",
    "        else:\n",
    "            return False\n",
    "        \n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        rt=[]\n",
    "        for x in range(left,right+1,1):\n",
    "            if self.isdividingNumber(x):\n",
    "                rt.append(x)\n",
    "        return rt\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        def self_dividing(n):\n",
    "            for d in str(n):\n",
    "                if d=='0' or n % int(d) > 0:\n",
    "                    return False\n",
    "            return True\n",
    "        \n",
    "        ans = []\n",
    "        for n in range(left,right+1):\n",
    "            if self_dividing(n):\n",
    "                ans.append(n)\n",
    "        return ans\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        str_i_l=[]\n",
    "        for i in range(left,right+1):\n",
    "            str_i=str(i)\n",
    "            if '0' in str_i:\n",
    "                continue\n",
    "            else:\n",
    "                str_i_l.append(str_i)\n",
    "        res=[]\n",
    "        for i in str_i_l:\n",
    "            if (all(int(i)%int(j)==0 for j in i)):\n",
    "                res.append(int(i))\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        res=[]\n",
    "        for n in range(left,right+1):\n",
    "            digit=n%10\n",
    "            nn=n\n",
    "            while digit!=0:\n",
    "                if nn%digit==0:\n",
    "                    n=n//10\n",
    "                    digit=n%10\n",
    "                else: \n",
    "                    break\n",
    "            if n ==0:\n",
    "                res.append(nn)\n",
    "            \n",
    "        return res\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: 'int', right: 'int') -> 'List[int]':\n",
    "        output = []\n",
    "        for i in range(left, right+1):\n",
    "            if '0' in str(i):\n",
    "                continue\n",
    "            flag = 1\n",
    "            for j in str(i):\n",
    "                if i%int(j)!=0:\n",
    "                    flag = 0\n",
    "                    break\n",
    "            if flag:\n",
    "                output.append(i)\n",
    "        return output"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        nums=[i for i in range(left,right+1)]\n",
    "        output=[]\n",
    "        for num in nums:\n",
    "            n=0\n",
    "            for i in str(num):\n",
    "                if i!='0' and num%int(i)==0:\n",
    "                    n+=1\n",
    "            if n==len(str(num)):\n",
    "                output.append(num)\n",
    "        return output\n",
    "               \n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left, right):\n",
    "        \"\"\"\n",
    "        :type left: int\n",
    "        :type right: int\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        s=0\n",
    "        l=[]\n",
    "        num_list = list(range(left,right+1))\n",
    "        for num in num_list:\n",
    "            for each in str(num):\n",
    "                if str(num).find('0') != -1:\n",
    "                    break\n",
    "                else:\n",
    "                    s = 0\n",
    "                    for each in str(num):\n",
    "                        if num % int(each) == 0:\n",
    "                            s+=1\n",
    "                    if s==len(str(num)):\n",
    "                        l.append(num)   \n",
    "        return sorted(list(set(l)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "            i = left\n",
    "            arr = []\n",
    "            while i <= right:\n",
    "                s = str(i)\n",
    "                flag = True\n",
    "                for c in s:\n",
    "                    if c == \"0\":\n",
    "                        flag = False\n",
    "                    else:\n",
    "                        flag = flag and i % int(c) == 0\n",
    "                if flag:\n",
    "                    arr.append(i)\n",
    "                i += 1\n",
    "            return arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        data = []\n",
    "        for i in range(left,right+1):\n",
    "            num = 0\n",
    "            if \"0\" in str(i):\n",
    "                continue\n",
    "            for j in str(i):\n",
    "                if i % int(j) == 0:\n",
    "                    num += 1\n",
    "            if num == len(str(i)):\n",
    "                data.append(i)\n",
    "        return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        res = []\n",
    "        i = left\n",
    "        while(i<=right):\n",
    "            temp = i\n",
    "            while(temp!=0 and (temp % 10) != 0 and i % (temp % 10) ==0):\n",
    "                temp = temp // 10\n",
    "            if (temp == 0 and i != 0):\n",
    "                res.append(i);\n",
    "            i += 1\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        res = []\n",
    "        for i in range(left, right+1):\n",
    "            if i == 0: continue\n",
    "            tmp = str(i)\n",
    "            c = 0\n",
    "            for s in tmp:\n",
    "                s = int(s)\n",
    "                if s == 0 or i % s != 0:\n",
    "                    break\n",
    "                c += 1\n",
    "            if c == len(tmp): res.append(i)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        def self_div(n):\n",
    "            for d in str(n):\n",
    "                if d=='0' or n % int(d) > 0:\n",
    "                    return False\n",
    "            return True\n",
    "        ans = []\n",
    "        for i in range(left, right+1):\n",
    "            if self_div(i):\n",
    "                ans.append(i)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "# class Solution:\n",
    "#   def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "#     def isSelfDeviding(n):\n",
    "#       s=str(n)\n",
    "#       if '0' in s: return False\n",
    "#       for ch in s:\n",
    "#         if int(s) % int(ch) != 0:\n",
    "#           return False\n",
    "#       return True\n",
    "    \n",
    "#     ans=[]\n",
    "#     for i in range(left, right+1):\n",
    "#       if isSelfDeviding(i):\n",
    "#         ans.append(i)\n",
    "#     return ans\n",
    "\n",
    "class Solution:\n",
    "  def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "    def self_dividing(n):\n",
    "      for d in str(n):\n",
    "        if d == '0' or n % int(d) > 0:\n",
    "          return False\n",
    "      return True\n",
    "\n",
    "    return list(filter(self_dividing, range(left, right+1)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        res = []\n",
    "        for i in range(left,right+1):\n",
    "            a = i\n",
    "            b = a%10 \n",
    "            while a>0 :\n",
    "                b = a%10 \n",
    "                if b == 0:\n",
    "                    break\n",
    "                if i%b!=0 :\n",
    "                    break\n",
    "                a = a//10\n",
    "            if b!=0 and i%b==0 :\n",
    "                res.append(i)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "def check(n : int) -> bool:\n",
    "    if n < 10:\n",
    "        return True\n",
    "    s = str(n)\n",
    "    for c in s:\n",
    "        if c == '0' or n % int(c) != 0:\n",
    "            return False\n",
    "    return True\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, l: int, r: int) -> List[int]:\n",
    "        ans = []\n",
    "        for i in range(l, r + 1):\n",
    "            if check(i):\n",
    "                ans.append(i)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        temp=list(range(left,right+1))\n",
    "        answer=list(range(left,right+1))\n",
    "        for x in temp:\n",
    "            if '0'  in str(x):\n",
    "                answer.remove(x)\n",
    "            else:\n",
    "                n=len(str(x))\n",
    "                y=x\n",
    "                for i in range(n):\n",
    "                    tempnum=y%10\n",
    "                    if x%tempnum!=0:\n",
    "                        answer.remove(x)\n",
    "                        break\n",
    "                    y=(y-tempnum)/10\n",
    "\n",
    "        return answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\r\n",
    "        list_n = list(range(left, right+1))\r\n",
    "        list_n = list(map(str, list_n))\r\n",
    "        res = []\r\n",
    "        for i in list_n:\r\n",
    "            for j in i:\r\n",
    "                if j == \"0\":\r\n",
    "                    break\r\n",
    "                if int(i) % int(j) != 0:\r\n",
    "                    break\r\n",
    "            else:\r\n",
    "                res.append(i)\r\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        lst1_no_zero=list(filter(lambda x:\"0\" not in x,map(str,range(left,right+1))))\n",
    "        lst2=[]\n",
    "        for i in lst1_no_zero:\n",
    "            for x in i:\n",
    "                if int(i)%int(x)!=0:\n",
    "                    lst2.append(int(i))\n",
    "        return list(filter(lambda x:x not in lst2,map(int,lst1_no_zero)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        def isSelfDividing(num: int):\n",
    "            x = num\n",
    "            while x:\n",
    "                x, d = divmod(x, 10)\n",
    "                if d == 0 or num % d:\n",
    "                    return False\n",
    "            return True\n",
    "        \n",
    "        return [i for i in range(left, right + 1) if isSelfDividing(i)]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        l1 = []\n",
    "        for i in range (left, right + 1):\n",
    "            p = 0\n",
    "            for k in range (len(str(i))):\n",
    "                if int(str(i)[k]) != 0 and i % int(str(i)[k]) == 0:\n",
    "                    p += 1\n",
    "            if p == len(str(i)):\n",
    "                l1.append(i)\n",
    "        return l1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        return [i for i in range(left, right + 1) if self.isSelfDividing(i)]\n",
    "\n",
    "    def isSelfDividing(self, num: int) -> bool:\n",
    "            x = num\n",
    "            while x:\n",
    "                x, d = divmod(x, 10)\n",
    "                if d == 0 or num % d:\n",
    "                    return False\n",
    "            return True\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        list1 = []\n",
    "        for i in range(left,right+1):\n",
    "            for j in str(i):\n",
    "                if j == '0':\n",
    "                    break\n",
    "                else:\n",
    "                    i = int(i)\n",
    "                    j = int(j)\n",
    "                    if i % j == 0:\n",
    "                        continue\n",
    "                    else:\n",
    "                        break\n",
    "            else:\n",
    "                list1.append(i)\n",
    "        return list1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        def chu(x):\n",
    "            a = 0\n",
    "            for i in list(str(x)):\n",
    "                i = int(i)\n",
    "                if i == 0:\n",
    "                    return False\n",
    "                    break\n",
    "                else:\n",
    "                    if x%i == 0:\n",
    "                        a = a + 1\n",
    "                    else:\n",
    "                        return False\n",
    "                        break\n",
    "            return True\n",
    "        return list(filter(chu,list(range(left,right+1))))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        res = []\n",
    "        ans = set()\n",
    "\n",
    "        b = list(map(str,range(left,right+1)))\n",
    "\n",
    "        for i in b:\n",
    "            for j in i:\n",
    "                if 0<int(i)<10:\n",
    "                    res.append(i)\n",
    "                if '0' in i:\n",
    "                    continue\n",
    "                if int(i) % int(j) == 0:\n",
    "                    res.append(i)\n",
    "        for i in res:\n",
    "            if res.count(i) > len(i)-1:\n",
    "                ans.add(i)\n",
    "        return sorted(list(map(int,ans)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        def check(num):\n",
    "            x = num\n",
    "            dd = []\n",
    "            while num:\n",
    "                dd.append(num % 10)\n",
    "                num //= 10\n",
    "            for a in dd:\n",
    "                if a==0 or x % a != 0:\n",
    "                    return False\n",
    "            return True\n",
    "        \n",
    "        return [num for num in range(left, right+1) if check(num)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        nums=[]\n",
    "        for i in range(left, right+1):\n",
    "            if str(i).count(\"0\"):\n",
    "                continue\n",
    "            fag=True\n",
    "            for j in str(i):\n",
    "                if(int(i)%int(j)!=0):\n",
    "                    fag=False\n",
    "                    break\n",
    "            if(fag==True):\n",
    "                nums.append(int(i))              \n",
    "        return nums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def selfDividingNumbers(self, left: int, right: int) -> List[int]:\n",
    "        nums=[]\n",
    "        for i in range(left, right+1):\n",
    "            if str(i).count(\"0\"):\n",
    "                continue\n",
    "            fag=True\n",
    "            for j in str(i):\n",
    "\n",
    "                if(int(i)%int(j)!=0):\n",
    "                    fag=False\n",
    "                    break\n",
    "            if(fag==True):\n",
    "                nums.append(int(i))              \n",
    "        return nums"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
